package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class JDBCDemo9 {
    public static void main(String[] args) throws SQLException {
        Connection connection = DBUtil.getConnection();
        String sql = "UPDATE userinfo " +
                "SET nickname = ?, age = ? " +
                "WHERE username = ?";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        preparedStatement.setString(1, "三三");
        preparedStatement.setInt(2, 18);
        preparedStatement.setString(3, "张三");
        int sum = preparedStatement.executeUpdate();
        System.out.println("修改了" + sum + "条记录");
    }
}
